package labuladong.动态规划;

public class 正则表达匹配 {

    public static boolean isMatch(String s1, String s2) {
        int s1Len = s1.length();
        int s2Len = s2.length();
        boolean[][] dp = new boolean[s1Len][s2Len];
        dp[0][0] =true;
        for (int i=1; i<s2Len; i++) {
            dp[0][i] = dp[0][i-1] && s2.charAt(i)=='*';
        }

        for (int i=1; i<=s1Len; i++) {
            for (int j=1; j<=s2Len; j++) {
                if (s1.charAt(i) == s2.charAt(j)) {
                    dp[i][j] = dp[i-1][j-1] || dp[i-1][j];
                }
            }
        }
        return true;
    }
}
